<template>
  <div class="count-box">
    <button @click="handleSub" class="minus">-</button>
    <input v-model="buyNum" class="inp" type="text" />
    <button @click="handleAdd" class="add">+</button>
  </div>
</template>  
  
<script lang="ts" setup>
import { ref } from "vue";
const buyNum = ref(1);
const handleSub = () => {
  if (buyNum.value > 0) {
    buyNum.value--;
  }
};
const handleAdd = () => {
  buyNum.value++;
};
</script>

<style lang="scss" scoped>
.count-box {
  width: 110px;
  display: flex;
  .add,
  .minus {
    width: 30px;
    height: 30px;
    outline: none;
    border: none;
    background-color: #efefef;
  }
  .inp {
    width: 40px;
    height: 30px;
    outline: none;
    border: none;
    margin: 0 5px;
    background-color: #efefef;
    text-align: center;
  }
}
</style>